import { defineStore } from 'pinia'
import { computed, ref } from 'vue'

const graphicalData = defineStore(
  'graphica',
  () => {
    const new_graphica = ref<
      {
        shapeIndex: number
        type: string
        points: { x: number; y: number }[]
      }[]
    >([])

    const graphicaValue = (
      newGraphica: {
        shapeIndex: number
        type: string
        points: { x: number; y: number }[]
      }[]
    ) => {
      new_graphica.value = newGraphica
    }

    const doubleNum = computed(() => new_graphica.value)

    return {
      new_graphica,
      graphicaValue,
      doubleNum
    }
  },
  {
    persist: {
      storage: sessionStorage,
      paths: ['new_graphica']
    }
  }
)

export default graphicalData